package com.eastfair.venueservice.service.impl;

import com.eastfair.core.base.R;
import com.eastfair.core.exception.BizException;
import com.eastfair.home.api.WorkOvertimeAuditFeign;
import com.eastfair.home.dto.WorkOvertimeAuditDTO;
import com.eastfair.venueservice.service.VenueManageWorkOvertimeAuditService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 主场加班申请审核服务.
 *
 * @author dqq
 * @date 2022 /10/20
 */
@Service
@Slf4j
public class VenueManageWorkOvertimeAuditServiceImpl implements VenueManageWorkOvertimeAuditService {

    @Resource
    private WorkOvertimeAuditFeign workOvertimeAuditFeign;

    @Override
    public boolean submitWorkOvertimeAudit(WorkOvertimeAuditDTO workOvertimeAuditDTO) {
        log.info("submitWorkOvertimeAudit - 提交加班申请审核, workOvertimeAuditDTO={}", workOvertimeAuditDTO);
        R<Boolean> result = workOvertimeAuditFeign.submitWorkOvertimeAudit(workOvertimeAuditDTO);
        log.info("submitWorkOvertimeAudit - 完成, result={}", result);
        if (!result.getIsSuccess()) {
            throw BizException.wrap(result.getCode(), result.getMsg());
        }
        return result.getData();
    }

    @Override
    public boolean cancelWorkOvertimeAudit(String workOvertimeNumber) {
        log.info("cancelWorkOvertimeAudit - 取消加班申请审核, workOvertimeNumber={}", workOvertimeNumber);
        R<Boolean> result = workOvertimeAuditFeign.cancelWorkOvertimeAudit(workOvertimeNumber);
        log.info("cancelWorkOvertimeAudit - 完成, result={}", result);
        if (!result.getIsSuccess()) {
            throw BizException.wrap(result.getCode(), result.getMsg());
        }
        return result.getData();
    }
}